
<%@page import="java.util.ArrayList"%>
<%@page import="transfer.Commodity"%>
<%@page import="content.CommodityContent"%>
<!--<div class="text-block">
    <img src="images/man.jpg" style="float: left;">
    <img src="images/two_hends.jpg" style="float: left; width: 250px; margin-right: 25px;">
    You are interested in home appliances, computers, software or goods for outdoor activities? All that you can buy right now, saving a lot of time! Online magazine Alpha-Store ? is happy to help you avoid having to visit dozens of shops. You can order any goods, rising from his chair, and our courier will deliver on time purchase to the address provided. Online Shop Alpha-Store ? operates throughout the country. Residents of any city can be a hassle to visit our online store.
    Regardless of where you are at the moment, you can order the product that you will agree, it is very convenient. What are the advantages offered by our online electronics store, phones and other items? The most important fact - the presence of thousands of positions that are guaranteed to have at the moment. You can visit our online store and buy any products at a low price. You need a refrigerator, a washing machine or a microwave oven?
</div>-->
<div class="block">
    <div class="block-header">Popular products</div>
    <%
        int count = 12;
        ArrayList goods = CommodityContent.getMostPopularGoods(count);
        double price = 0;
        for (int i = 0; i < goods.size(); i++) {
            Commodity c = (Commodity) goods.get(i);
            String imagePath = "images/commodity/" + c.getImage();
    %>
    <div class="box-prod" id="<% out.print(c.getIdCommodity()); %>">    
        <a href="index.jsp?content=view&id=<%= c.getIdCommodity() %>">
            <div class="img-cont"><img src="<% out.print(imagePath); %>"></div>
        <h4><% out.print(c.getNameCommodity()); %></h4>
        </a>
        <p>
            <% price = c.getPrice().doubleValue();
                if((Math.round(price) - price) == 0)
                    out.print((int)price + " $");
                else
                    out.print(price + " $");
            %> 
        </p>
        
            <div class="btn-buy-cont" id="buy_button" >
                <%
                    if (!c.getOutOfProduction().booleanValue()) {
                %>
                        <input type="button" value="buy" class="btn-buy" onclick="addCommodity($(this).parent().parent().attr('id'));" />
                <% 
                    }
                %>                    
            </div>
        </div>           
    <% 
        }
    %>   
</div>